#!/bin/sh

arg_num=$#	# 传递到脚本的参数个数

if [ $arg_num -gt 0 ];then
    if [ $1 == "0" ];then
        echo "execute command: rmmod sdriver_demo.ko"
        rmmod sdriver_demo.ko
        echo ""
    elif [ $1 == "1" ];then
        echo "execute command: insmod sdriver_demo.ko"
        insmod sdriver_demo.ko
        echo ""
    elif [ $1 == "2" ];then
        echo "execute command: ./app_demo.out /dev/sdevchr"
        ./app_demo.out /dev/sdevchr 
    elif [ $1 == "3" ];then
        echo "execute command: ./app_demo.out /dev/sdevchr &"
        ./app_demo.out /dev/sdevchr &
        echo "execute command: ./app_demo.out /dev/sdevchr &"
        ./app_demo.out /dev/sdevchr &
    fi
    exit 0
else
    echo "usage:"
    echo "      $0 0 # unload module"
    echo "      $0 1 # load module"
    echo "      $0 2 # run app_demo.out"
    echo "      $0 3 # run app_demo.out * 2"
    exit 0
fi
